<template>
  <div class="account-create-wrap">
    <createTop firstMenu="账户管理" secondMenu="我的账户" title="账户管理"></createTop>
    <el-card shadow="always" v-loading="loading">
      <div class="content">
        <div class="content-title">账号 <span class="red-icon">※</span></div>
          <el-input disabled :style="{'width':'350px'}" placeholder="系统自动获取"></el-input>
        <div class="content-title">密码 <span class="red-icon">※</span></div>
          <el-input :style="{'width':'350px'}" align="left" v-model="pwd" placeholder="请输入新密码"></el-input>
      </div>
      <saveBtn @confirm="confirm"></saveBtn>
    </el-card>
  </div>
</template>
<script lang="ts">
import Vue from 'vue';
import Component from 'vue-class-component';
import createTop from '@/components/createTop.vue';
import saveBtn from '@/components/saveBtn.vue';
import ajaxResquest from '@/api/apiRequest';

@Component({
  components: {
    createTop,
    saveBtn
  }
})
export default class MyCount extends Vue {
  createRes!: ajaxResquest;
  username: string = '';
  pwd: string = '';
  loading: boolean = false;
  mounted() {
    this.createRes = new ajaxResquest('/account/update');
  }
  confirm(): void {
    let data: any = {
      username: this.username,
      pwd: this.pwd,
      // role_id: this.role,
      // remark: this.remark
    }
      if (
        this.username == '' &&
        this.pwd == ''
      ) {
        this.$message.error('全部参数为空不能提交');
        return;
      }
    this.createRes.getFunction(data).then((res:any) => {
      if(res.data.code===1){
        sessionStorage.removeItem('token');
        this.$router.replace({ name: 'login' });
        this.$message.success('修改成功,请重新登录');
      }
    });
  }
}
</script>
<style lang="less">
.account-create-wrap {
  height: 100%;
  padding: 15px;
  display: flex;
  flex-direction: column;
  z-index: 101;
  box-sizing: border-box;
  .el-card {
    overflow-y: auto;
  }
  .content {
    display: flex;
    flex-direction: column;
    font-size: 16px;
    background-color: #fff;
    border-radius: 4px;
    .content-title {
      height: 40px;
      margin-top: 20px;
      line-height: 2;
      text-align: left;
    }
    .short-input {
      width: 100%;
      width: 240px;
      margin-right: 10px;
    }
    .el-upload-list__item {
      width: 350px;
    }
    .el-textarea {
      margin-bottom: 30px;
    }
  }
}
</style>
